package com.taikang.common.util.hibernate;

import java.util.List;

/** * 封装分页和查询的结果. * * @param Page中的记录类型. */
public class Page<T> implements java.io.Serializable {
	/** * */
	private static final long serialVersionUID = -3167350028645121914L;
	private int start = 0;
	private int limit = 20;
	private int totalCount = -1;
	private List<T> result = null;

	public Page() {
	}

	public Page(int start, int limit) {
		this.start = start;
		this.limit = limit;
	}

	/** * 页内的数据列 */
	public List<T> getResult() {
		return result;
	}

	public void setResult(List<T> result) {
		this.result = result;
	}

	/** * 总记录数. */
	public int getTotalCount() {
		return totalCount;
	}

	public void setTotalCount(int totalCount) {
		this.totalCount = totalCount;
	}

	/** * 计算总页�? */
	public int getTotalPages() {
		if (totalCount == -1)
			return -1;

		int count = totalCount / limit;
		if (totalCount % limit > 0) {
			count++;
		}
		return count;
	}

	public int getStart() {
		return start;
	}

	public void setStart(int start) {
		this.start = start;
	}

	public int getLimit() {
		return limit;
	}

	public void setLimit(int limit) {
		this.limit = limit;
	}

}